//Copyright (C) 2013 Julio Espindola
//
//This file is part of VSize Checkers.
//
//VSize Checkers is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//VSize Checkers is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with VSize Checkers.  If not, see <http://www.gnu.org/licenses/>.

package checkers;

class Entry
{
    long hash;
    short score;
    short moveIndex;
    short depth;
    boolean exact;
   
    Entry(long hash, int score, int moveIndex, int depth, boolean exact)
    {
        this.hash = hash;
        this.score = (short) score;
        this.moveIndex = (short) moveIndex;
        this.depth = (short) depth;
        this.exact = exact;
    }
}

class Table
{
    static final int ENTRIES_NUM = 2000000;
    Entry[] entries = new Entry[ENTRIES_NUM];
   
    Entry getEntry(long hashValue)
    {
        Entry e = entries[(int)(hashValue % entries.length)];
        return (e != null && e.hash == hashValue) ? e : null;
    }
   
    void storeEntry(Entry e)
    {
        entries[(int)(e.hash % entries.length)] = e;
    }
   
    void resetTable()
    {
        entries = new Entry[ENTRIES_NUM];
        System.gc();
    }
}
